package com.sunlei.webtest.controller;

/**
 * Created by 001 on 2017/7/19.
 */
import com.sunlei.webtest.bean.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/dome")
public class UserController {

    @RequestMapping("/testJson")
    public User testJson() {
        User user = new User();
        user.setName("lijia");
        user.setAge(27);
        user.setAddress("北京");
        return user;
    }

    @RequestMapping("/testJson2")
    public List<User> testJson2(@RequestParam(value = "username", required = true) String name,
                               @RequestParam(value = "password", required = true) String pwd) {
        User user = new User();
        user.setName(name);
        user.setAge(27);
        user.setAddress("北京");

        User user2 = new User();
        user2.setName(name);
        user2.setAge(27);
        user2.setAddress("北京");
        List<User> data = new ArrayList<User>();
        data.add(user);
        data.add(user2);
        return data;
    }

}
